package com.pat.miniloyalty;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
//import javax.jdo.annotations.Key;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.users.User;

@PersistenceCapable
public class TranData
{
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Persistent
	private String uid;
	
	@Persistent
	private User company;
	
	@Persistent
	private Date createdAt;

	@Persistent
	private int sumInMinorCurrency;
	
	@Persistent
	private int statusId;

	/**
	 * Creates transaction, which status is pending. Need to be approved
	 * @param uid User/Client ID
	 * @param company company/merchant
	 * @param sumInMinorCurrency sum of purchase 
	 */
	public TranData(String uid, User company, int sumInMinorCurrency)
	{
		this.uid = uid;
		this.company = company;
		this.sumInMinorCurrency = sumInMinorCurrency;
		this.createdAt = new Date();
		this.statusId = MyConstants.STATUS_PENDING;
	}
	
	public Key getKey()
	{
		return key;
	}
	
	public String getUid()
	{
		return uid;
	}

	public User getCompany()
	{
		return company;
	}
	
	public Date getCreatedAt()
	{
		return createdAt;
	}
	
	public int getSumInMinorCurrency()
	{
		return sumInMinorCurrency;
	}
	
	public int getStatusId()
	{
		return statusId;
	}

	public void setUid(String v)
	{
		uid = v;
	}
	
	public void setCompany(User v)
	{
		company = v;
	}
	
	public void setCreatedAt(Date v)
	{
		createdAt = v;
	}
	
	public void setSumInMinorCurrency(int v)
	{
		sumInMinorCurrency = v;
	}
	
	public void setStatusId(int v)
	{
		// TODO: check if status is valid!
		statusId = v;
	}
}
